package nowcoder.offer;

/**
 * 二叉树的深度
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-08-28 10:31
 */
public class TreeDepth {

    private int max = 0;

    public int solution(TreeNode root){
        helper(root,0);
        return max;
    }

    public void helper(TreeNode node,int depth){
        if (node == null){
            max = Math.max(max,depth);
            return;
        }
        helper(node.left,depth+1);
        helper(node.right,depth+1);

    }


    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        System.out.println(new TreeDepth().solution(root));
    }
}
